<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>login</title>
    <link type="text/css" rel="stylesheet" th:href="@{/css/login.css}"/>
    <script src="/js/jquery.min.js" type="text/javascript"></script>
    <script src="/js/vue.min.js" type="text/javascript"></script>
    <script src="/js/axios.min.js" type="text/javascript"></script>
</head>
<body>

<div class="container">
    <div class="login-wrapper">
        <div class="header">Login</div>
        <form id="app" method="post">
            <div class="form-wrapper">
                <input type="text" name="username" placeholder="username" v-model="registform.username"
                       class="input-item">
                <input type="password" name="password" placeholder="password" v-model="registform.password"
                       class="input-item">
                <input id="login" type="button" class="btn" value="login" @click="toLogin">
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    var vue = new Vue({
        el: "#app",
        data: {
            registform: {
                username: "",
                password: "",
                // username:"qwq"
            }
        },
        methods: {
            toLogin: function () {
                let datata = this.registform;
                var url = "/user/doLogin";
                axios.post(url, datata).then(function (response) {
                    var redata = response.data;
                    if (redata.code === 200) {
                        alert(redata.msg)
                        window.location.href = "../manager/listToEmails";
                    } else {
                        alert(redata.msg);
                    }
                })
            }
        }
    })
</script>

</body>
</html>
